<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<script type="text/javascript" language="JavaScript">
    $(document).ready(function() {
        $("#add-hotel-mapping").validate();
    });
    function list_hotel() {
        $("#list_hotel_form").attr("action", "list.dhtml");
        $("#list_hotel_form").submit();
    }
    function add_hotel(obj) {
        obj.preventDefault();
        window.location.href = "view.dhtml";
    }
    function query_hotel(obj) {
        var hotelMappingId = obj.parent().parent().children("input:hidden").eq(0).val();
        var hotelMappingIdNode = "<input type=\"hidden\" name=\"hotelMapping.id\" value=\"" + hotelMappingId + "\"/>";
        $("#list_hotel_form").append(hotelMappingIdNode);
        $("#list_hotel_form").attr("action", "view.dhtml?hotelMapping.id=");
        $("#list_hotel_form").submit();
    }
    function show_add_div(obj) {
        obj.preventDefault();
        window.location.href = "list.dhtml";
    }
    function show_hotel_list_div() {
        $("#add_hotel_div").hide();
        $("#hotel_list").show();
    }
    $(function() {
        $("#edit_hotel_form").validate();
    })
</script>
<h1>Hotel</h1>

<div class="main">
    <div class="box_side search_hotel clearfix">
        <form id="list_hotel_form" method="GET">
            <ul>
                <li><label>IHG Hotel Code：</label>
                    <s:textfield name="hotelMapping.cooperatorCode" cssClass="text"/>
                </li>
                <li><label>Derby Hotel Code：</label>
                    <s:textfield id="derbyCode" name="hotelMapping.derbyCode" size="45" cssClass="text"/>
                </li>
                <li><label>IHG Hotel Name：</label>
                    <s:textfield name="hotelMapping.hotelName" cssClass="text"/>
                </li>
                <li><label>Status：</label>
                    <s:select name="hotelMapping.status" cssClass="select" value="hotelMapping.status"
                              list="@com.derbysoft.dswitch.adapter.ihg.common.domain.HotelStatus@values()"/>
                </li>
            </ul>
            <input type="button" value="Search" onclick="list_hotel();" class="common_button">
        </form>
    </div>
</div>
<s:if test="newHotelMapping==null">
    <div class="main" id="hotel_list">
        <jsp:include page="../../../common/pagination.jsp"/>
        <div align="right">
            <input class="common_button" type="button" value="Add"
                   onclick="window.location.href='./view.dhtml'">
            <input class="common_button" type="button" value="Import"
                   onclick="window.location.href='./importView.dhtml'">
        </div>
        <table id="channel" class="table_list" cellpadding="0" cellspacing="0">
            <thead>
            <tr>
                <th>IHG Hotel Code</th>
                <th>Derby Hotel Code</th>
                <th>IHG Hotel Name</th>
                <th>Status</th>
                <th>Create Date</th>
                <th>Operate</th>
            </tr>
            </thead>
            <tbody>
            <s:iterator value="paginater.objects">
                <tr>
                    <td>${cooperatorCode}</td>
                    <td>${derbyCode}</td>
                    <td>${hotelName}</td>
                    <td>${status}</td>
                    <td><s:date name="createTime" format="yyyy-MM-dd HH:mm"/></td>
                    <td><a href="edit.dhtml?hotelMapping.id=${id}">Edit</a></td>
                </tr>
            </s:iterator>
            </tbody>
        </table>
        <jsp:include page="../../../common/pagination.jsp"/>
    </div>
</s:if>
<s:form id="edit_hotel_form" method="post">
    <s:if test="newHotelMapping!=null">
        <div class="main">
            <jsp:include page="../../../common/messages.jsp"/>
            <h1>Edit Hotel Mapping</h1>
            <ul>
                <li style="margin-left:50px;">
                    <label>IHG Hotel Code：</label>
                    <input type="hidden" name="hotelMapping.id" value="${newHotelMapping.id}">
                    <input name="hotelMapping.cooperatorCode" value="${newHotelMapping.cooperatorCode}" readonly="true">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <label>Derby Hotel Code：</label>
                    <input name="hotelMapping.derbyCode" class="required" maxlength="50"
                           value="${newHotelMapping.derbyCode}" size="50">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <label>IHG Hotel Name：</label>
                    <input name="hotelMapping.hotelName" value="${newHotelMapping.hotelName}">
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <label>Status：</label>
                    <s:select name="hotelMapping.status" cssClass="select" value="newHotelMapping.status"
                              list="@com.derbysoft.dswitch.adapter.ihg.common.domain.HotelStatus@values()"/>
                    <input value="Update" class="common_button" type="button" onclick="edit_hotel();">
                    <input value="Back" class="common_button" type="button" onclick="list_hotel();">
                </li>
            </ul>
        </div>
    </s:if>
</s:form>



